<!DOCTYPE html>
<html lang="zh_CN">
<head>
  <script>if (window !== top) top.location.replace(location.href);</script>
  <meta charset="utf-8"/>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="icon" href="${ctxPath}/assets/images/favicon.ico">
  <title>用户登录-Snowy快速开发框架</title>
  <link rel="stylesheet" href="${ctxPath}/assets/libs/layui/css/layui.css"/>
  <link rel="stylesheet" href="${ctxPath}/assets/module/admin.css">
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
  <style>
    body {
      background-color: #FFFFFF;
      background-image: url("${ctxPath}/assets/images/xn_login.jpg");
      background-repeat: no-repeat;
      background-size: contain;
      min-height: 100vh;
    }

    body:before {
      content: "";
      background-color: rgba(0, 0, 0, .2);
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
    }

    .login-wrapper {
      max-width: 420px;
      padding: 20px;
      margin: 0 auto;
      position: relative;
      box-sizing: border-box;
      z-index: 2;
    }

    .login-wrapper > .layui-form {
      padding: 25px 30px;
      background-color: #fff;
      box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.19);
      box-sizing: border-box;
    }

    .login-wrapper > .layui-form > h2 {
      color: #333;
      font-size: 18px;
      text-align: center;
      margin-bottom: 25px;
    }

    .login-wrapper > .layui-form > .layui-form-item {
      margin-bottom: 25px;
      position: relative;
    }

    .login-wrapper > .layui-form > .layui-form-item:last-child {
      margin-bottom: 0;
    }

    .login-wrapper > .layui-form > .layui-form-item > .layui-input {
      height: 46px;
      line-height: 46px;
      border-radius: 2px !important;
    }

    .login-wrapper .layui-input-icon-group > .layui-input {
      padding-left: 46px;
    }

    .login-wrapper .layui-input-icon-group > .layui-icon {
      width: 46px;
      height: 46px;
      line-height: 46px;
      font-size: 20px;
      color: #909399;
      position: absolute;
      left: 0;
      top: 0;
      text-align: center;
    }

    .login-wrapper > .layui-form > .layui-form-item.login-captcha-group {
      padding-right: 135px;
    }

    .login-wrapper > .layui-form > .layui-form-item.login-captcha-group > .login-captcha {
      height: 46px;
      width: 120px;
      cursor: pointer;
      box-sizing: border-box;
      border: 1px solid #e6e6e6;
      border-radius: 2px !important;
      position: absolute;
      right: 0;
      top: 0;
    }

    .login-wrapper > .layui-form > .layui-form-item > .layui-form-checkbox {
      margin: 0 !important;
      padding-left: 25px;
    }

    .login-wrapper > .layui-form > .layui-form-item > .layui-form-checkbox > .layui-icon {
      width: 15px !important;
      height: 15px !important;
    }

    .login-wrapper > .layui-form .layui-btn-fluid {
      height: 48px;
      line-height: 48px;
      font-size: 16px;
      border-radius: 2px !important;
    }

    .login-wrapper > .layui-form > .layui-form-item.login-oauth-group > a > .layui-icon {
      font-size: 26px;
    }

    .login-copyright {
      color: #eee;
      padding-bottom: 20px;
      text-align: center;
      position: relative;
      z-index: 1;
    }

    @media screen and (min-height: 550px) {
      .login-wrapper {
        margin: -300px auto 0;
        position: absolute;
        top: 50%;
        left: 0;
        right: 0;
        width: 100%;
      }

      .login-copyright {
        position: absolute;
        bottom: 0;
        right: 0;
        left: 0;
      }
    }

    .layui-btn {
      background-color: #5FB878;
      border-color: #5FB878;
    }

    .layui-link {
      color: #5FB878 !important;
    }
    .snowy-title {
      height: 44px;
      line-height: 44px;
      text-align: center;
      margin-bottom: 40px
    }
    .snowy-title-img {
      height: 44px;
      vertical-align: top;
      border-style: none;
    }
    .snowy-title-span {
      font-size: 33px;
      color: rgba(0,0,0,.85);
      font-family: Avenir,Helvetica Neue,Arial,Helvetica,sans-serif;
      font-weight: 600;
      position: relative;
      top: 2px;
    }
  </style>
</head>
<body>
<div class="login-wrapper layui-anim layui-anim-scale layui-hide">
  <div class="snowy-title">
    <!--
            <img src="${ctxPath}/assets/images/logo.png" class="snowy-title-img">
    -->
    <span class="snowy-title-span">泰州职业技术学院</span>
  </div>
  <form class="layui-form">
    <h2>用户注册</h2>
    <div class="layui-form-item layui-input-icon-group">
      <i class="layui-icon layui-icon-username"></i>
      <input class="layui-input" name="account" placeholder="请输入身份证号" autocomplete="off"
             lay-verType="tips" lay-verify="required|idcards" required/>
    </div>
    <div class="layui-form-item layui-input-icon-group">
      <i class="layui-icon layui-icon-username"></i>
      <input class="layui-input" name="name" placeholder="请输入姓名" autocomplete="off"
             lay-verType="tips" lay-verify="required" required/>
    </div>
    <div class="layui-form-item layui-input-icon-group">
      <i class="layui-icon layui-icon-password"></i>
      <input class="layui-input" name="password" placeholder="请输入登录密码" type="password"
             lay-verType="tips" lay-verify="required|pass" required/>
    </div>
    <div class="layui-form-item layui-input-icon-group">
      <i class="layui-icon layui-icon-password"></i>
      <input class="layui-input" name="confirmpassword" placeholder="确认密码" type="password"
             lay-verType="tips" lay-verify="required|repass|pass" required/>
    </div>

    <!--        <div class="layui-form-item">
                <input type="checkbox" name="remember" title="记住密码" lay-skin="primary" checked>
                <a href="reg.html" class="layui-link pull-right">注册账号</a>
            </div>-->
    <div class="layui-form-item">
      <button class="layui-btn layui-btn-fluid" lay-filter="loginSubmit" lay-submit>注册</button>
    </div>
    <% if(constantContext.getEnableOauthLogin()) { %>
    <div class="layui-form-item login-oauth-group text-center">
      <a href="javascript:;"><i class="layui-icon layui-icon-login-qq" style="color:#3492ed;"></i></a>&emsp;
      <a href="javascript:;"><i class="layui-icon layui-icon-login-wechat" style="color:#4daf29;"></i></a>&emsp;
      <a href="javascript:;"><i class="layui-icon layui-icon-login-weibo" style="color:#CF1900;"></i></a>
    </div>
    <% } %>
  </form>
</div>


<!-- js部分 -->
<script src="${ctxPath}/assets/libs/layui/layui.js"></script>
<script src="${ctxPath}/assets/js/common.js"></script>
<script>
  layui.use(['layer', 'form', 'notice', 'index'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
    var form = layui.form;
    var notice = layui.notice;
    var admin = layui.admin;
    var index = layui.index;

    $('.login-wrapper').removeClass('layui-hide');

    //如果有提示，则显示提示
    var errorMsg = '${tips!}';
    if (errorMsg) {
      notice.msg(errorMsg, {icon: 2});
    }


    // 自定义验证规则
    form.verify({
      idcards: function(value, item){ // 身份证号码验证规则
        if(value.length != 16 && value.length != 18){
          return '身份证号码长度应为16或18位';
        }
      },
      pass: function(value, item){ // 密码验证规则
        if(!/^[a-zA-Z0-9`~!@#$%^&*()-=_+\\\[\]{}|;':",./<>?]+$/.test(value)){
          return '密码只能包含字母、数字和符号';
        }
        if(value.length < 6 || value.length > 12){
          return '密码长度应为6到12位';
        }
      },
      repass: function(value, item){ // 重复密码验证规则
        var password = $('input[name="password"]').val(); // 获取密码输入框的值
        if(value !== password){
          return '两次输入的密码不相等';
        }
      }
    });

    /* 表单提交 */
    form.on('submit(loginSubmit)', function (data) {
      layer.load(2);
      admin.req(getProjectUrl() + 'zhuce', JSON.stringify(data.field), function(res){

      }, 'post');
      layer.msg('注册成功', {icon: 1, time: 3000}, function () {
        // 先将页签记忆清空，以免上次登陆的用户的菜单对于此次登录的用户无权限而跳转到403页面
        index.clearTabCache();
        layer.load(2);
        location.href = getProjectUrl();
      });
      return false;
    });


  });
</script>
</body>
</html>
